/**
 * @생성일 : 2011. 9. 14.
 * @package : com.luffy.sample
 * 
 *
 */
package com.luffy.sample;

import java.util.Random;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.luffy.message.creator.MessageCreator;

/**
 * <pre>
 * 역할적기.
 * </pre>
 * @작성자 : Administrator
 * @작성일 : 2011. 9. 14.
 * @package : com.luffy.sample
 *
 */
@Controller
@RequestMapping("/app/")
public class ApiSample {
	@RequestMapping("success")
	public void success(ModelMap model) {
		model.addAttribute("result", MessageCreator.getSuccessMessage());
	}

	@RequestMapping("error")
	public void error(ModelMap model) {
		model.addAttribute("error", MessageCreator.getDefaultErrorMessage());
	}

	@RequestMapping("result")
	public void result(ModelMap model) {
		model.addAttribute("result", MessageCreator.getResultMessage(getSampleLotto()));
	}

	private LottoModel getSampleLotto() {
		LottoModel lottoModel = new LottoModel();
		Random random = new Random();
		lottoModel.getNumList().add(random.nextInt(46));
		lottoModel.getNumList().add(random.nextInt(46));
		lottoModel.getNumList().add(random.nextInt(46));
		lottoModel.getNumList().add(random.nextInt(46));
		lottoModel.getNumList().add(random.nextInt(46));
		lottoModel.getNumList().add(random.nextInt(46));
		return lottoModel;
	}
}
